<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>树形菜单</title>
    <link rel="stylesheet" type="text/css" href="./layui/css/layui.css" />
    <link rel="stylesheet" type="text/css" href="./layui_ext/dtree/dtree.css" />
    <link rel="stylesheet" type="text/css" href="./layui_ext/dtree/font/dtreefont.css " />
    <script src="./layui/layui.js" type="text/javascript" content="utf-8"></script>
</head>
<body>
    <ul id="demoTree1" class="dtree" data-id="0"></ul>

    <script>
    layui.config({
        base: 'layui/lay/modules/' //配置 layui 第三方扩展组件存放的基础目录
      }).extend({
        dtree: 'dtree' //定义该组件模块名
      }).use(['element','layer', 'dtree'], function(){
          var layer = layui.layer,
              dtree = layui.dtree,
              $ = layui.$;
          dtree.render({
            elem: "#demoTree1",  //绑定元素
            url: "./json/demoTree1.json"  //异步接口
          });
              //单击节点 监听事件
              dtree.on("node('demoTree1')" ,function(param){
            layer.msg(JSON.stringify(param));
          });
      });
      </script>  



</body>
</html>